package com.siki.vo.admin;

import com.siki.pojo.commonEntity.Enterprise;
import com.siki.pojo.commonEntity.GeneralUser;
import com.siki.pojo.commonEntity.SysUser;
import com.siki.pojo.enumeration.common.AuditStatus;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Optional;

/**
 * @Author Siki
 * @Date 2020/6/7
 */
@ApiModel("查询全部账号列表VO")
@Getter
@Setter
@NoArgsConstructor
public class FindAllEnterpriseVO {
    @ApiModelProperty("id")
    String id;

    @ApiModelProperty("名称")
    String realName;

    @ApiModelProperty("审核状态")
    String auditStatus;

    @ApiModelProperty("是否被禁止[如果为空则不显示]")
    Boolean forbid;

    public FindAllEnterpriseVO(SysUser sysUsers) {
        Optional.ofNullable(sysUsers).ifPresent(sysUser -> {
            //账号id
            this.id=sysUser.getId();
            //企业名称
            this.realName = sysUser.getRealName();
            //审核状态
            this.auditStatus = Optional.ofNullable(sysUser.getAuditStatus()).map(AuditStatus::getName).orElse(null);
            //禁止状态
            this.forbid = Optional.ofNullable(sysUser.getGeneralUser()).map(GeneralUser::getForbid).orElse(null);
        });
    }
}
